<?php
namespace app\admin\controller;

use think\Db;
use app\common\controller\AdminBase;
use app\common\model\Xdmsg as XdmsgModel;

class Screen extends AdminBase
{
    public function index($page = 1){
        $keyword = Db::name('screen')->paginate(15,false,['page' => $page]);

        return $this->fetch('index',['keyword'=>$keyword,'page' => $page]);
    }

    public function add(){
        return $this->fetch();
    }

    public function save(){
        $data = $this->request->post();
        $data['create_time'] = date('Y-m-d H:i:s');
        $result = Db::name('screen')->insert($data);
        if ($result) {
            $this->success('保存成功');
        } else {
            $this->error("保存失败");
        }
    }

    public function delete($id){
        $result = Db::name('screen')->where('id',$id)->delete();
        if ($result) {
            $this->success('删除成功');
        } else {
            $this->error("删除失败");
        }
    }
}